package leetcode;

public class 最小公倍数_最大公因数 {
    // 暴力法
    public static int min_test(int a,int b) {
        if(a>b) {
            int temp = a;
            a=b;
            b=temp;
        }
        int result=0;
        for (int i = a; i >=1; i--) {
            if(b%i==0&&a%i==0) {
                result = i;
                break;
            }
        }
        return result;
    }
    // 辗转相除法
    public static int zhanzhuan_test(int a,int b) {
        if(a>b) {
            int temp = a;
            a=b;
            b=temp;
        }
        while (true) {
            int temp =b%a;
            if (temp==0) {
                break;
            }
            b=a;
            a=temp;
        }
        return a;
    }
    public static void main(String[] args) {
        System.out.println(min_test(5,10));
        System.out.println(zhanzhuan_test(5,10));
    }
}
